﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace uacars
{
    public partial class frmBarraMenu : Form
    {
        public frmBarraMenu()
        {
            InitializeComponent();
        }

        private void salirToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            if (MessageBox.Show("Desea salir de la aplicación?", "Salir", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                //Cerrar el padre
                Application.Exit();
            }
        }

        private void cerrarSesiónToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Desea cerrar sesión?", "Cerrar Sesión", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                this.ParentForm.MdiChildren[2].Close();
                this.ParentForm.MdiChildren[1].Close();

                frmLogin fLog = new frmLogin();

                fLog.MdiParent = this.ParentForm;

                //Cierra el formulario actual
                this.Close();
                fLog.Show();
            }
        }

        private void clientesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.MdiChildren.Length == 3)
            {
                frmClientes Clientes = new frmClientes();
                Clientes.MdiParent = this.MdiParent;
                Clientes.Show();
            }
            else
            {
                if (this.ParentForm.MdiChildren[3].Name.ToString() != "frmClientes")
                {

                    frmClientes Clientes = new frmClientes();
                    Clientes.MdiParent = this.MdiParent;
                    Clientes.Show();
                    this.ParentForm.MdiChildren[3].Close();
                }
            }
            //btnCitas.Image = uacars.Properties.Resources.citas;
            //btnClientes.Image = uacars.Properties.Resources.clientesC;
            //btnEmpleados.Image = uacars.Properties.Resources.empleados;
            //btnVehiculos.Image = uacars.Properties.Resources.productos;
            //btnPedidos.Image = uacars.Properties.Resources.ventas;
            //btnOfertas.Image = uacars.Properties.Resources.ofertas;
        }

        private void empleadosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.MdiChildren.Length == 3)
            {
                frmEmpleados Empleados = new frmEmpleados();
                Empleados.MdiParent = this.MdiParent;
                Empleados.Show();
            }
            else
            {
                if (this.ParentForm.MdiChildren[3].Name.ToString() != "frmEmpleados")
                {

                    frmEmpleados Empleados = new frmEmpleados();
                    Empleados.MdiParent = this.MdiParent;
                    Empleados.Show();
                    this.ParentForm.MdiChildren[3].Close();
                }
            }
            //btnCitas.Image = uacars.Properties.Resources.citas;
            //btnClientes.Image = uacars.Properties.Resources.clientes;
            //btnEmpleados.Image = uacars.Properties.Resources.empleadosC;
            //btnVehiculos.Image = uacars.Properties.Resources.productos;
            //btnPedidos.Image = uacars.Properties.Resources.ventas;
            //btnOfertas.Image = uacars.Properties.Resources.ofertas;
        }

        private void vehículosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.MdiChildren.Length == 3)
            {
                frmVehiculos Vehiculos = new frmVehiculos();
                Vehiculos.MdiParent = this.MdiParent;
                Vehiculos.Show();
            }
            else
            {
                if (this.ParentForm.MdiChildren[3].Name.ToString() != "frmVehiculos")
                {
                    frmVehiculos Vehiculos = new frmVehiculos();
                    Vehiculos.MdiParent = this.MdiParent;
                    Vehiculos.Show();
                    this.ParentForm.MdiChildren[3].Close();
                }
            }
            //btnCitas.Image = uacars.Properties.Resources.citas;
            //btnClientes.Image = uacars.Properties.Resources.clientes;
            //btnEmpleados.Image = uacars.Properties.Resources.empleados;
            //btnVehiculos.Image = uacars.Properties.Resources.productosC;
            //btnPedidos.Image = uacars.Properties.Resources.ventas;
            //btnOfertas.Image = uacars.Properties.Resources.ofertas;
        }

        private void ventasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.MdiChildren.Length == 3)
            {
                frmPedidos Pedidos = new frmPedidos();
                Pedidos.MdiParent = this.MdiParent;
                Pedidos.Show();
            }
            else
            {
                if (this.ParentForm.MdiChildren[3].Name.ToString() != "frmPedidos")
                {

                    frmPedidos Pedidos = new frmPedidos();
                    Pedidos.MdiParent = this.MdiParent;
                    Pedidos.Show();
                    this.ParentForm.MdiChildren[3].Close();
                }
            }

            //btnCitas.Image = uacars.Properties.Resources.citas;
            //btnClientes.Image = uacars.Properties.Resources.clientes;
            //btnEmpleados.Image = uacars.Properties.Resources.empleados;
            //btnVehiculos.Image = uacars.Properties.Resources.productos;
            //btnPedidos.Image = uacars.Properties.Resources.ventasC;
            //btnOfertas.Image = uacars.Properties.Resources.ofertas;
        }

        private void ofertasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.MdiChildren.Length == 3)
            {
                frmOfertas Ofertas = new frmOfertas();
                Ofertas.MdiParent = this.MdiParent;
                Ofertas.Show();
            }
            else
            {
                if (this.ParentForm.MdiChildren[3].Name.ToString() != "frmOfertas")
                {

                    frmOfertas Ofertas = new frmOfertas();
                    Ofertas.MdiParent = this.MdiParent;
                    Ofertas.Show();
                    this.ParentForm.MdiChildren[3].Close();
                }
            }
            //btnCitas.Image = uacars.Properties.Resources.citas;
            //btnClientes.Image = uacars.Properties.Resources.clientes;
            //btnEmpleados.Image = uacars.Properties.Resources.empleados;
            //btnVehiculos.Image = uacars.Properties.Resources.productos;
            //btnPedidos.Image = uacars.Properties.Resources.ventas;
            //btnOfertas.Image = uacars.Properties.Resources.ofertasC;
        }

        private void citasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.MdiChildren.Length == 3)
            {
                DataTable tmp = new DataTable();
                frmCitas Citas = new frmCitas(tmp);
                Citas.MdiParent = this.MdiParent;
                Citas.Show();
            }
            else
            {
                if (this.ParentForm.MdiChildren[3].Name.ToString() != "frmCitas")
                {
                    DataTable tmp = new DataTable();
                    frmCitas Citas = new frmCitas(tmp);
                    Citas.MdiParent = this.MdiParent;
                    Citas.Show();
                    this.ParentForm.MdiChildren[3].Close();
                }
            }

            //btnCitas.Image = uacars.Properties.Resources.citasC;
            //btnClientes.Image = uacars.Properties.Resources.clientes;
            //btnEmpleados.Image = uacars.Properties.Resources.empleados;
            //btnVehiculos.Image = uacars.Properties.Resources.productos;
            //btnPedidos.Image = uacars.Properties.Resources.ventas;
            //btnOfertas.Image = uacars.Properties.Resources.ofertas;
        }
    }
}
